package com.cw.DesignModel23.Structural.ProxyPattern.静态代理;

/**
 * 订单服务静态代理类
 */
public class OrderServiceStaticProxy {
    private IOrderService iOrderService;

    public OrderServiceStaticProxy(IOrderService iOrderService) {
        this.iOrderService = iOrderService;
    }

    public int saveOrder(Order order){
        beforeMethod();
        int result = iOrderService.saveOrder(order);
        afterMethod();
        return result;
    }

    /**
     * 在被代理对象方法之前执行的内容
     */
    private void beforeMethod() {
        System.out.println("静态代理 OrderServiceStaticProxy 执行 saveOrder 之前");
    }

    /**
     * 在被代理对象方法之后执行的内容
     */
    private void afterMethod() {
        System.out.println("静态代理 OrderServiceStaticProxy 执行 saveOrder 之后");
    }
}

